/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pt.our.angemc.datatypes;

/**
 *
 * @author piskeiro
 */
public abstract class Symbol {
    private String name;
    private Multiplier multiplier;
    private boolean notMatch;
    private final String notMatchRepresentation="~";

    public Symbol(String name, Multiplier multiplier,boolean notMatch) {
        this.name = name;
        this.multiplier = multiplier;
        this.notMatch=notMatch;
    }

    public String getNotMatchStringRepresentation(){
        if(notMatch){
            return notMatchRepresentation;
        }
        return "";
    }

    public void setNotMatch(boolean notMatch) {
        this.notMatch = notMatch;
    }

    public boolean isNotMatch() {
        return notMatch;
    }

    public Multiplier getMultiplier() {
        return multiplier;
    }

    public String getName() {
        return name;
    }

    public void setMultiplier(Multiplier multiplier) {
        this.multiplier = multiplier;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public abstract Symbol clone();

    @Override
    public String toString(){
        return (name+multiplier.getMultiplierRepresentationAsString().trim());
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Symbol other = (Symbol) obj;
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        if (this.multiplier != other.multiplier && (this.multiplier == null || !this.multiplier.equals(other.multiplier))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        return hash*getName().hashCode();
    }


}